package com.best.design.template.good;

/**
 * @author Jiang Akang
 * employeeId: BG435424
 * @date 2021/10/20
 **/


import java.io.IOException;
import java.util.Map;

/**
 * 基础电商推广服务
 * 1. 生成最优价商品海报
 * 2. 海报含带推广邀请码
 */
public abstract class NetMall {

    // 用户Id
    private final String uId;

    // 用户密码
    private final String uPwd;

    public NetMall(String uId, String uPwd) {
        this.uId = uId;
        this.uPwd = uPwd;
    }

    // 模拟登录
    protected abstract Boolean login(String uId, String uPwd);

    // 爬虫提取商品信息(登录后的优惠价格)
    protected abstract Map<String, String> reptile(String skuUrl) throws IOException;

    // 生成商品海报信息
    protected abstract String createBase64(Map<String, String> goodsInfo);

    public String generateGoodsPoster(String skuUrl) throws IOException {
        // 1. 验证登录
        if (!login(uId, uPwd)) {
            return null;
        }
        // 2. 爬虫商品
        Map<String, String> reptile = reptile(skuUrl);
        return createBase64(reptile);

    }

}
